package com.le.tester.leetcode;

import com.le.tester.leetcode.common.TreeNode;
import org.apache.commons.math3.geometry.euclidean.threed.RotationOrder;

import java.util.Objects;

/**
 * currentTime:2022/3/9 16:47
 * description:所求的路径总和
 */
public class PathSum {

    public boolean hasPathSum(TreeNode root, int targetSum) {


        if (Objects.isNull(root)) {
            return false;
        }

        if (Objects.isNull(root.left) && Objects.isNull(root.right)) {
            return targetSum == root.val;
        }

        return this.hasPathSum(root.left, targetSum - root.val)
                || this.hasPathSum(root.right, targetSum - root.val);
    }
}
